import {Component, Vue, Prop, Watch} from 'vue-property-decorator';
import {ButtonItem} from '@/utils/interfaces';
import AppButton from '@/components/common/app-button/index.vue';

@Component({
  components: {
    AppButton
  }
})
export default class AppModalFooter extends Vue {
  @Prop({
    required: false,
    default: () => [],
  }) items!: ButtonItem[];
  @Prop({
    required: false,
    default: () => {
    },
  })
  parentEl!: any;

  beforeDestroy() {
    this.items.forEach((i: any) => {
      i?.handler?.$el?.removeEventListener('click', i.handler);
    })
  }

  isShow(item: any) {
    if (!Object.prototype.hasOwnProperty.call(item, 'show')) return true;
    if (typeof (item.show) === 'string') return this.parentEl[item.show];
    return item.show;
  }

}